<?php
/**
* @name Default Controller
* @access public
*/
class Default_Controller extends Controller {
	function __construct()
	{
		parent::__construct();
	}

	public function index()
	{
		$post = ORM::factory('post')->find_all();
		foreach($post as $posts) {
			echo '标题：<a href='.url::site('default/show/'.$posts->id).'>'.$posts->title.'</a>，作者：'.$posts->user->username.'<br/>';
		}
//    echo '文章标题：'.$post->title.'<br/>';
//		echo '文章内容：'.$post->text.'<br/>';
//		echo '文章作者：'.$post->user->username.'<br/>===================<br/>';
//		foreach($post->comment as $comments) {
//			echo '评论有：'.$comments->text.'<br/>';
//			echo '评论作者：'.$comments->user->username.'<br/>';
//		}
	}
	
	public function show($post_id) {
		$post = ORM::factory('post')->where('id', $post_id)->find();
		echo '文章标题：'.$post->title.'，作者：'.$post->user->username.'<br/>';
		echo '文章内容：'.$post->text.'<br/>========================<br/>';
		foreach($post->comment as $comments) {
			echo '<font style=\'font-size:12px\'>评论内容：'.$comments->text.'，作者：'.$comments->user->username.'</font><br/>';
		}
		echo '<a href=\'javascript:history.back(-1)\'>返回</a>';
	}
}
?>